<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.se.data.CapturedRequest" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 

<jsp:useBean id="requests" scope="request" type="java.util.List" />

<html>
  <head>
    <title>Most Recent Requests</title>
    <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  </head>

  <body>
    <h1>Most Recent Requests</h1>
    <c:forEach var="capturedRequest" items="${requests}">
      <c:choose>
        <c:when test="${capturedRequest.tag == null}">
          <p><a href="/detail?id=${capturedRequest.id}"><c:out value="${capturedRequest.title}" /></a> | <c:out value="${capturedRequest.timestamp}" /></p>
        </c:when>
        <c:otherwise>
          <p><a href="/detail?id=${capturedRequest.id}&tag=${capturedRequest.tag}"><c:out value="${capturedRequest.title}" /></a> | <c:out value="${capturedRequest.timestamp}" /></p>
        </c:otherwise>
      </c:choose>
    </c:forEach>
  </body>
</html>